import java.io.*;
import java.net.*;
import java.util.*;
public class Server {
    public static void main(String args[]) {
        Skey_kb n = new Skey_kb();

        ServerSocket serverForClient=null;
        Socket socketOnServer=null;
        DataOutputStream out=null;
        DataInputStream  in=null;
        MyDC evaluator = new MyDC();
        int result=0;
        try { serverForClient = new ServerSocket(2010);
        }
        catch(IOException e1) {
            System.out.println(e1);
        }
        try{
            String tempofreturn;
            System.out.println("watting for client");
            socketOnServer = serverForClient.accept(); //zusezhuangtai
            out=new DataOutputStream(socketOnServer.getOutputStream());
            in=new DataInputStream(socketOnServer.getInputStream());

            String s=in.readUTF(); // in duquxingxi
            System.out.println("get c:");
            System.out.println("receive s ="+s);
            tempofreturn=n.dec(s);
            System.out.println("解密后信息:"+tempofreturn);
            result = evaluator.evaluate(tempofreturn);


            out.writeUTF(Integer.toString(result));
            Thread.sleep(500);

        }
        catch(Exception e) {
            System.out.println("Client out"+e);
        }
    }
}